package com.itheima.edu.info.manager.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public final class DateUtil {
    public static int getAgeByBirthday(String bithday)  {
        int age = 0;
        try {
            SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd");
            Date dateTime = format1.parse(bithday);
            Date now = new Date();
            Long ageTime = now.getTime() - dateTime.getTime();
            age = (int) (ageTime / 1000 / 60 / 60/24/365);

        } catch (ParseException e) {
        }
       return age;
    }
}
